package com.ego.e.dialog

import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import com.e.ego.R

import com.github.ybq.android.spinkit.sprite.Sprite
import kotlinx.android.synthetic.main.dialog_loading.*

/**
 * Created by lxy on 2016/7/15.
 */
class ELoading(context: Context) : Dialog(context, R.style.loading_dialog) {

    init {
        init(context)
    }

    private fun init(context: Context) {
        val view = LayoutInflater.from(context).inflate(R.layout.dialog_loading, null)
        setContentView(view)
        setCancelable(false)
        setCanceledOnTouchOutside(false)
    }

    fun sprite(sprite: Sprite) {
        skv_loading.setIndeterminateDrawable(sprite)
    }

    fun loading() = loading("")

    fun loading(text: Int) {
        try {
            tv_loading.setText(text)
            show()
        } catch (e: Exception) {
            return
        }
    }

    fun loading(text: String) {
        try {
            tv_loading.text = text
            show()
        } catch (e: Exception) {
            return
        }
    }


}
